home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsincludes / egslayers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-06  |  11.6 KB  |  317 lines

  1. #ifndef EGS_EGSLAYERS_H
  2. #define EGS_EGSLAYERS_H
  3.  
  4. /***************************************************************************\
  5. *
  6. *  $
  7. *  $ FILE     : egslayers.h
  8. *  $ VERSION  : 1
  9. *  $ REVISION : 3
  10. *  $ DATE     : 08-Dec-93 12:45
  11. *  $
  12. *  $ Author   : mvk
  13. *  $
  14. *
  15. *****************************************************************************
  16. *                                                                           *
  17. * (c) Copyright 1990/94 VIONA Development                                   *
  18. *     All Rights Reserved                                                   *
  19. *                                                                           *
  20. \***************************************************************************/
  21.  
  22. #ifndef         EXEC_TYPES_H
  23. #include        <exec/types.h>
  24. #endif
  25. #ifndef         EXEC_PORTS_H
  26. #include        <exec/ports.h>
  27. #endif
  28. #ifndef         EXEC_LISTS_H
  29. #include        <exec/lists.h>
  30. #endif
  31. #ifndef         EXEC_SEMAPHORES_H
  32. #include        <exec/semaphores.h>
  33. #endif
  34. #ifndef         EGS_EGS_H
  35. #include        <egs/egs.h>
  36. #endif
  37. #ifndef         EGS_EGSBLIT_H
  38. #include        <egs/egsblit.h>
  39. #endif
  40.  
  41.  
  42.  
  43. /*
  44.  * This library manages overlapping, independent, rectangular screen areas
  45.  * (layers). They form the base of each window system.
  46.  *
  47.  * Layers can be moved, sized and put from front to back or vice versa. The
  48.  * library offers adequate functions. Areas to be clipped, hidden and
  49.  * restored are held in lists of "ClipRects". That structure is defined in
  50.  * EGSBlit so there are no complications for clipping.
  51.  *
  52.  * Currently four kinds of layers are supported:
  53.  *
  54.  * - no care refresh : Layer parts hidden by other layers are never refreshed.
  55.  *                     No list of rectangles to be refreshed is kept.
  56.  *                     This layer kind is recommended if the layer's contents
  57.  *                     are automatically refreshed in constant intervals,
  58.  *                     e.g. for animation.
  59.  *
  60.  * - simple refresh  : The library keeps a list which contains the parts that
  61.  *                     need refreshing. If this list changes, i.e. if refresh
  62.  *                     is needed, an appropriate message is sent to a given
  63.  *                     port.
  64.  *                     Then the program should refresh it's display. For this,
  65.  *                     "BeginRefresh" and "EndRefresh" claim the part to be
  66.  *                     refreshed as the current drawing area so that only the
  67.  *                     damaged screen parts are drawn into during refresh.
  68.  *                     This layer kind is the best compromise between memory
  69.  *                     usage and execution speed. It should be used whenever
  70.  *                     possible since layers saving their hidden parts eat
  71.  *                     a lot of memory in high resolution graphics.
  72.  *
  73.  * - super bitmap    : These layers own a Bitmap that can greatly exceed the
  74.  *                     visible portion. The layer forms a window over this
  75.  *                     BitMap that you may move as you like. Damaged screen
  76.  *                     areas are refreshed by restoring them with data from
  77.  *                     this special background BitMap. This layer's disad-
  78.  *                     vantage is the gigantic memory requirement. You should
  79.  *                     use them only if really necessary, e.g. pixel oriented
  80.  *                     graphics.
  81.  *
  82.  * - smart refresh   : For all obscured areas, these layers create restoring
  83.  *                     areas which are managed dynamically and are later
  84.  *                     freed automatically.
  85.  *                     So you need not pay attention to refresh as drawing
  86.  *                     operations are performed even in these restoring areas.
  87.  *                     But a refresh message is sent as soon as the layer is
  88.  *                     sized.
  89.  *                     The disadvantage of this layer is its gigantic memory
  90.  *                     usage especially for big bit depths.  You should
  91.  *                     use this type in such screens scarcely.
  92.  *
  93.  */
  94.  
  95.  
  96.  
  97. /*
  98.  * LayerFlags, LayerFlagSet
  99.  *
  100.  * - SIMPLE_REFRESH  : Set if "simple refresh layer".
  101.  * - SUPER_BITMAP    : Set if "super bitmap layer".
  102.  * - SMART_REFRESH   : Set if "smart refresh layer".
  103.  *
  104.  * - IN_REFRESH      : Layer is currently being refreshed.
  105.  * - NEW_TO_REFRESH...
  106.  * - TO_REFRESH      : Layer needs a refresh.
  107.  * - NO_BACKFILL     : If an obscured layer part is made visible, this part
  108.  *                     is filled with the layer's background colour.  If this
  109.  *                     flag is set then no fill occurs. This saves time if
  110.  *                     the part will be overwritten completely during refresh
  111.  *                     anyway (e.g. window border).
  112.  * - CLIPS_INVALID   : The layer was modified after this flag had been cleared
  113.  *                     the last time.  You can use this flag to put an addi-
  114.  *                     tional Clip region over the layer.
  115.  * - BACKDROP        : The layer lies behind all non-backdrop-layers.
  116.  *
  117.  */
  118.  
  119. /* Corresponding LayerFlagSet has 32 bits ! */
  120.  
  121. #define EL_SIMPLE_REFRESH (1<<0)
  122. #define EL_SUPER_BITMAP   (1<<1)
  123. #define EL_IN_REFRESH     (1<<2)
  124. #define EL_NEW_TO_REFRESH (1<<3)
  125. #define EL_TO_REFRESH     (1<<4)
  126. #define EL_NO_BACKFILL    (1<<5)
  127. #define EL_OBSOLETE1      (1<<6)
  128. #define EL_BACKDROP       (1<<7)
  129. #define EL_SMART_REFRESH  (1<<8)
  130.  
  131. typedef struct EL_LayerInfo *EL_LayerInfoPtr;
  132.  
  133. /*
  134.  * Layer, LayerPtr
  135.  *
  136.  * Structure for management of a layer.
  137.  *
  138.  * !!! READ-ONLY !!!
  139.  *
  140.  * .Front,
  141.  * .Back      : Chaining.
  142.  * .LayerInfo : Pointer to assigned "AreaInfo" structure.
  143.  * .MaxBorder : Maximum layer size in screen coordinates.
  144.  * .Border    : Maximum visible area of the layer on the screen.
  145.  * .FrontClip : Clip area for drawing onto the visible area. The area is the
  146.  *              union of all specified ClipRects.
  147.  * .BackClip  : Clip area for drawing into the background BitMap (only for
  148.  *              super bitmap).  The border is specified in screen coordinates
  149.  *              and might be adjusted when necessary.
  150.  * .FrontMap  : Front Bitmap.
  151.  * .BackMap   : Background BitMap, NIL if missing.
  152.  * .Damage    : List of damaged screen areas.
  153.  * .Flags     : Flags (what else ?)
  154.  * .Lock      : Layer's lock. A layer must be locked before using elements
  155.  *              from it since operations with other layers might change them.
  156.  * .Window    : Slave pointer pointing to the corresponding window.
  157.  * .ExtData   : PRIVATE !
  158.  * .BackColor : Background colour of the layer.
  159.  * .DispX,
  160.  * .DispY     : Coordinates of the top left point in layer coordinates.
  161.  * .Key       : Current refresh key (refer to "BeginUpdate").
  162.  * .ClipKey   : actuall version of the layer, is incremented by one by any
  163.  *              layer operation that modifies the cliprects.
  164.  * .BackHook  : Current hook for layer back fill operations.
  165.  *
  166.  *                               Layer, .MmaxBorder
  167.  *          DispX               /
  168.  *         /     \             /
  169.  *        /+-------------------------+
  170.  *  DispY| |                         |
  171.  *        \|     #############---------- visible area, .Border
  172.  *         |     #############       |
  173.  *         |     #############       |
  174.  *         |     #############       |
  175.  *         |     #############       |
  176.  *         |     #############       |
  177.  *         |     #############       |
  178.  *         |     #############       |
  179.  *         |     #############       |
  180.  *         |                         |
  181.  *         |                         |
  182.  *         +-------------------------+
  183.  *
  184.  * Layers should always be created and changed with the library functions as
  185.  * support for disk-based BitMaps will be added and the structure will be
  186.  * extended certainly.
  187.  */
  188.  
  189. typedef struct EL_SmartClip *EL_SmartPtr;
  190.  
  191. struct EL_SmartClip {                      /* PRIVATE */
  192.  
  193.         struct EB_ClipRect Cliprect;
  194.         E_EBitMapPtr       EMapp;
  195.         WORD               DispX, DispY;
  196.         E_EBitMapPtr       EMap;
  197. };
  198.  
  199. typedef struct EL_BackHook *EL_BackHookPtr;
  200.  
  201. /*
  202.  * EL_BackHook
  203.  *
  204.  * Descriptive structure for layer and layer info back fill function.
  205.  * Calling conventions are:
  206.  *
  207.  *  A0 map      : E_EBitMapPtr  : map to fill in
  208.  *  A1 UserData : APTR          : own user data from hook
  209.  *  D0 x        : WORD          : left edge of rectangle
  210.  *  D1 y        : WORD          : top edge of rectangle
  211.  *  D2 w        : WORD          : width of rectangle
  212.  *  D3 h        : WORD          : height of rectangle
  213.  *  D4 ox       : WORD          : left offset of rectangle in full rectangle
  214.  *  D5 oy       : WORD          : top offset of rectangle in full rectangle
  215.  *
  216.  * Use this structure only in conjunction with EL_InstallLHook and
  217.  * EL_InstallLIHook, never change the field in a layer or layerinfo structure
  218.  * directly.
  219.  *
  220.  */
  221.  
  222. struct EL_BackHook {
  223.         VOID   (*Call)();
  224.         APTR   UserData;
  225. };
  226.  
  227. typedef struct EL_Layer *EL_LayerPtr;
  228.  
  229. struct EL_Layer {
  230.  
  231.         EL_LayerPtr             front, back;
  232.         EL_LayerInfoPtr         LayerInfo;
  233.         struct EB_ClipRect      MaxBorder, Border;
  234.         EB_ClipRectPtr          FrontClip, BackClip;
  235.         E_EBitMapPtr            FrontMap, BackMap;
  236.         EB_ClipRectPtr          Damage;
  237.         EB_ClipRectPtr          FrontSave, BackSave;
  238.         ULONG                   Flags;
  239.         struct SignalSemaphore  Lock;
  240.         WORD                    Pad_1;
  241.         APTR                    Window;
  242.         APTR                    ExtData;
  243.         LONG                    BackColor;
  244.         WORD                    DispX, DispY;
  245.         LONG                    Key;
  246.         LONG                    ClipKey;
  247.         EL_BackHookPtr          BackHook;
  248. };
  249.  
  250.  
  251.  
  252. /*
  253.  * LayerInfo, LayerInfoPtr
  254.  *
  255.  * Interface structure between a BitMap and the layers that use it. This
  256.  * structure must be created if layers are to be used.
  257.  *
  258.  * !!! READ-ONLY !!!
  259.  *
  260.  * .First        : Front layer on the screen.
  261.  * .Last         : Layer on the screen behind all other layers.
  262.  * .AllLocks     : Super-lock for all locks in the liste; if several layers
  263.  *                 of a screen are to be locked, this semaphore must be locked
  264.  *                 first (refer to "LockLayers" and "LockLayerInfo").
  265.  * .Map          : BitMap of that screen which the layers are belonging to.
  266.  * .Port         : Message port that refresh messages are sent to.
  267.  * .BackColor    : Background colour.
  268.  * .BackPattern  : Background pattern; if specified then the screen's back
  269.  *                 ground is filled with the pattern, otherwise the background
  270.  *                 colour is used.  The pattern can have any size, the size
  271.  *                 depends on its BitMap.
  272.  * .Border       : Border coordinates of the BitMap; a kind of ClipRect with
  273.  *                 highest priority.
  274.  *
  275.  * LayerInfo structures should always be created and changed with the library
  276.  * functions since it is possible that they are extended in future.
  277.  */
  278.  
  279. struct EL_LayerInfo {
  280.  
  281.         EL_LayerPtr             First, Last;
  282.         struct SignalSemaphore  Lock;
  283.         WORD                    Pad_1;
  284.         struct List             AllLocks;
  285.         WORD                    Pad_2;
  286.         E_EBitMapPtr            Map;
  287.         struct MsgPort         *Port;
  288.         LONG                    BackColor;
  289.         E_EBitMapPtr            BackPattern;
  290.         struct EB_ClipRect      Border;
  291.         EL_BackHookPtr          BackHook;
  292. };
  293.  
  294.  
  295.  
  296. /*
  297.  * LayerMsg, LayerMsgPtr
  298.  *
  299.  * Message that is sent when a layer wants refreshing.
  300.  *
  301.  * .Layer   : Layer to be refreshed.
  302.  * .Key     : Current refresh key of the layer (refer to "BeginUpdate").
  303.  *
  304.  * This message must be replied after having received it.
  305.  */
  306.  
  307. typedef struct EL_LayerMsg *EL_LayerMsgPtr;
  308.  
  309. struct EL_LayerMsg {
  310.         struct Message          Msg;
  311.         EL_LayerPtr             Layer;
  312.         LONG                    Key;
  313. };
  314.  
  315.  
  316. #endif   /*  EGS_EGSLAYERS_H */
  317.